<!DOCTYPE HTML>
<html lang="zh-hans" >
    
    <head>
        
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <title>5.课程2:使用 ANSI SQL 查询 | Apache Drill</title>
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <meta name="description" content="">
        <meta name="generator" content="GitBook 2.6.6">
        <meta name="author" content="smartloli">
        
        <meta name="HandheldFriendly" content="true"/>
        <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
        <link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">
        
    <link rel="stylesheet" href="../../gitbook/style.css">
    
        
        <link rel="stylesheet" href="../../gitbook/plugins/gitbook-plugin-tbfed-pagefooter/footer.css">
        
    
        
        <link rel="stylesheet" href="../../gitbook/plugins/gitbook-plugin-highlight/website.css">
        
    
        
        <link rel="stylesheet" href="../../gitbook/plugins/gitbook-plugin-fontsettings/website.css">
        
    
    

        
    
    
    <link rel="next" href="../../3.教程/4.在 MapR 的 Sandbox 中学习 Drill/6.课程3:查询复杂的数据类型.html" />
    
    
    <link rel="prev" href="../../3.教程/4.在 MapR 的 Sandbox 中学习 Drill/4.课程1:学习数据集.html" />
    

        
    </head>
    <body>
        
        
    <div class="book"
        data-level="3.4.5"
        data-chapter-title="5.课程2:使用 ANSI SQL 查询"
        data-filepath="3.教程/4.在 MapR 的 Sandbox 中学习 Drill/5.课程2:使用 ANSI SQL 查询.md"
        data-basepath="../.."
        data-revision="Fri Aug 26 2016 12:40:11 GMT+0800 (CST)"
        data-innerlanguage="">
    

<div class="book-summary">
    <nav role="navigation">
        <ul class="summary">
            
            
            
                
                <li>
                    <a href="http://drill.smartloli.org" target="blank" class="custom-link">Apache Drill</a>
                </li>
            
            

            
            <li class="divider"></li>
            

            
    
        <li class="chapter " data-level="0" data-path="index.html">
            
                
                    <a href="../../index.html">
                
                        <i class="fa fa-check"></i>
                        
                        前言
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1" >
            
            <span><b>1.</b> 1.开始</span>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.1" data-path="1.开始/1.Introduction 介绍.html">
            
                
                    <a href="../../1.开始/1.Introduction 介绍.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.1.</b>
                        
                        1.Introduction 介绍
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="1.开始/2.Why Drill 为什么使用 Drill.html">
            
                
                    <a href="../../1.开始/2.Why Drill 为什么使用 Drill.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.2.</b>
                        
                        2.Why Drill 为什么使用 Drill
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2" >
            
            <span><b>2.</b> 2.架构</span>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.1" data-path="2.架构/1.Architecture Introduction 架构介绍.html">
            
                
                    <a href="../../2.架构/1.Architecture Introduction 架构介绍.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.1.</b>
                        
                        1.Architecture Introduction 架构介绍
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.2" data-path="2.架构/2.Drill Query Execution Drill 查询执行.html">
            
                
                    <a href="../../2.架构/2.Drill Query Execution Drill 查询执行.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.2.</b>
                        
                        2.Drill Query Execution Drill 查询执行
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.3" data-path="2.架构/3.Core Modules 核心模块.html">
            
                
                    <a href="../../2.架构/3.Core Modules 核心模块.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.3.</b>
                        
                        3.Core Modules 核心模块
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.4" data-path="2.架构/4.Performance 性能.html">
            
                
                    <a href="../../2.架构/4.Performance 性能.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.4.</b>
                        
                        4.Performance 性能
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3" >
            
            <span><b>3.</b> 3.教程</span>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.1" data-path="3.教程/1.Tutorials Introduction 教程介绍.html">
            
                
                    <a href="../../3.教程/1.Tutorials Introduction 教程介绍.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.1.</b>
                        
                        1.Tutorials Introduction 教程介绍
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.2" data-path="3.教程/2.Drill in 10 Minutes 快速指导.html">
            
                
                    <a href="../../3.教程/2.Drill in 10 Minutes 快速指导.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.2.</b>
                        
                        2.Drill in 10 Minutes 快速指导
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.3" data-path="3.教程/3.A-Y-A-D 数据集分析.html">
            
                
                    <a href="../../3.教程/3.A-Y-A-D 数据集分析.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.3.</b>
                        
                        3.A-Y-A-D 数据集分析
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.4" >
            
            <span><b>3.4.</b> 4.在 MapR 的 Sandbox 中学习 Drill</span>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.4.1" data-path="3.教程/4.在 MapR 的 Sandbox 中学习 Drill/1.关于 MapR 的 Sandbox.html">
            
                
                    <a href="../../3.教程/4.在 MapR 的 Sandbox 中学习 Drill/1.关于 MapR 的 Sandbox.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.4.1.</b>
                        
                        1.关于 MapR 的 Sandbox
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.4.2" data-path="3.教程/4.在 MapR 的 Sandbox 中学习 Drill/2.在 Sandbox 中安装 Drill.html">
            
                
                    <a href="../../3.教程/4.在 MapR 的 Sandbox 中学习 Drill/2.在 Sandbox 中安装 Drill.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.4.2.</b>
                        
                        2.在 Sandbox 中安装 Drill
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.4.3" data-path="3.教程/4.在 MapR 的 Sandbox 中学习 Drill/3.在 Sandbox 中使用 Drill.html">
            
                
                    <a href="../../3.教程/4.在 MapR 的 Sandbox 中学习 Drill/3.在 Sandbox 中使用 Drill.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.4.3.</b>
                        
                        3.在 Sandbox 中使用 Drill
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.4.4" data-path="3.教程/4.在 MapR 的 Sandbox 中学习 Drill/4.课程1:学习数据集.html">
            
                
                    <a href="../../3.教程/4.在 MapR 的 Sandbox 中学习 Drill/4.课程1:学习数据集.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.4.4.</b>
                        
                        4.课程1:学习数据集
                    </a>
            
            
        </li>
    
        <li class="chapter active" data-level="3.4.5" data-path="3.教程/4.在 MapR 的 Sandbox 中学习 Drill/5.课程2:使用 ANSI SQL 查询.html">
            
                
                    <a href="../../3.教程/4.在 MapR 的 Sandbox 中学习 Drill/5.课程2:使用 ANSI SQL 查询.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.4.5.</b>
                        
                        5.课程2:使用 ANSI SQL 查询
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.4.6" data-path="3.教程/4.在 MapR 的 Sandbox 中学习 Drill/6.课程3:查询复杂的数据类型.html">
            
                
                    <a href="../../3.教程/4.在 MapR 的 Sandbox 中学习 Drill/6.课程3:查询复杂的数据类型.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.4.6.</b>
                        
                        6.课程3:查询复杂的数据类型
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.4.7" data-path="3.教程/4.在 MapR 的 Sandbox 中学习 Drill/7.总结.html">
            
                
                    <a href="../../3.教程/4.在 MapR 的 Sandbox 中学习 Drill/7.总结.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.4.7.</b>
                        
                        7.总结
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3.5" data-path="3.教程/5.高度动态的数据集分析.html">
            
                
                    <a href="../../3.教程/5.高度动态的数据集分析.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.5.</b>
                        
                        5.高度动态的数据集分析
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.6" data-path="3.教程/6.社会媒体分析.html">
            
                
                    <a href="../../3.教程/6.社会媒体分析.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.6.</b>
                        
                        6.社会媒体分析
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.7" data-path="3.教程/7.使用窗口函数分析数据.html">
            
                
                    <a href="../../3.教程/7.使用窗口函数分析数据.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.7.</b>
                        
                        7.使用窗口函数分析数据
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="4" >
            
            <span><b>4.</b> 4.安装 Drill</span>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.1" data-path="4.安装 Drill/1.Drill 安装介绍.html">
            
                
                    <a href="../../4.安装 Drill/1.Drill 安装介绍.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.1.</b>
                        
                        1.Drill 安装介绍
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.2" data-path="4.安装 Drill/2.迁移 Parquet 数据.html">
            
                
                    <a href="../../4.安装 Drill/2.迁移 Parquet 数据.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.2.</b>
                        
                        2.迁移 Parquet 数据
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.3" >
            
            <span><b>4.3.</b> 3.安装 Drill 到嵌入模式</span>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.3.1" data-path="4.安装 Drill/3.安装 Drill 到嵌入模式/1.嵌入模式的先决条件.html">
            
                
                    <a href="../../4.安装 Drill/3.安装 Drill 到嵌入模式/1.嵌入模式的先决条件.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.3.1.</b>
                        
                        1.嵌入模式的先决条件
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.3.2" data-path="4.安装 Drill/3.安装 Drill 到嵌入模式/2.在 Linux 和 Mac OS X 上安装 Drill.html">
            
                
                    <a href="../../4.安装 Drill/3.安装 Drill 到嵌入模式/2.在 Linux 和 Mac OS X 上安装 Drill.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.3.2.</b>
                        
                        2.在 Linux 和 Mac OS X 上安装 Drill
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.3.3" data-path="4.安装 Drill/3.安装 Drill 到嵌入模式/3.在 Linux 和 Mac OS X 上启动 Drill.html">
            
                
                    <a href="../../4.安装 Drill/3.安装 Drill 到嵌入模式/3.在 Linux 和 Mac OS X 上启动 Drill.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.3.3.</b>
                        
                        3.在 Linux 和 Mac OS X 上启动 Drill
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.3.4" data-path="4.安装 Drill/3.安装 Drill 到嵌入模式/4.在 Windows 上安装 Drill.html">
            
                
                    <a href="../../4.安装 Drill/3.安装 Drill 到嵌入模式/4.在 Windows 上安装 Drill.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.3.4.</b>
                        
                        4.在 Windows 上安装 Drill
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.3.5" data-path="4.安装 Drill/3.安装 Drill 到嵌入模式/5.在 Windows 上启动 Drill.html">
            
                
                    <a href="../../4.安装 Drill/3.安装 Drill 到嵌入模式/5.在 Windows 上启动 Drill.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.3.5.</b>
                        
                        5.在 Windows 上启动 Drill
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="4.4" >
            
            <span><b>4.4.</b> 4.安装 Drill 到分布式模式</span>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.4.1" data-path="4.安装 Drill/4.安装 Drill 到分布式模式/1.分布式模式的先决条件.html">
            
                
                    <a href="../../4.安装 Drill/4.安装 Drill 到分布式模式/1.分布式模式的先决条件.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.4.1.</b>
                        
                        1.分布式模式的先决条件
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.4.2" data-path="4.安装 Drill/4.安装 Drill 到分布式模式/2.在集群上安装 Drill.html">
            
                
                    <a href="../../4.安装 Drill/4.安装 Drill 到分布式模式/2.在集群上安装 Drill.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.4.2.</b>
                        
                        2.在集群上安装 Drill
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.4.3" data-path="4.安装 Drill/4.安装 Drill 到分布式模式/3.在分布式模式下启动 Drill.html">
            
                
                    <a href="../../4.安装 Drill/4.安装 Drill 到分布式模式/3.在分布式模式下启动 Drill.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.4.3.</b>
                        
                        3.在分布式模式下启动 Drill
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="4.5" data-path="4.安装 Drill/5.启动 Web 控制台.html">
            
                
                    <a href="../../4.安装 Drill/5.启动 Web 控制台.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.5.</b>
                        
                        5.启动 Web 控制台
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="5" >
            
            <span><b>5.</b> 5.配置 Drill</span>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="5.1" data-path="5.配置 Drill/1.配置介绍.html">
            
                
                    <a href="../../5.配置 Drill/1.配置介绍.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.1.</b>
                        
                        1.配置介绍
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.2" data-path="5.配置 Drill/2.配置内存.html">
            
                
                    <a href="../../5.配置 Drill/2.配置内存.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.2.</b>
                        
                        2.配置内存
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.3" >
            
            <span><b>5.3.</b> 3.配置一个多租户集群</span>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="5.3.1" data-path="5.配置 Drill/3.配置一个多租户集群/1.配置一个多租户介绍.html">
            
                
                    <a href="../../5.配置 Drill/3.配置一个多租户集群/1.配置一个多租户介绍.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.3.1.</b>
                        
                        1.配置一个多租户介绍
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.3.2" data-path="5.配置 Drill/3.配置一个多租户集群/2.配置多租户资源.html">
            
                
                    <a href="../../5.配置 Drill/3.配置一个多租户集群/2.配置多租户资源.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.3.2.</b>
                        
                        2.配置多租户资源
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.3.3" data-path="5.配置 Drill/3.配置一个多租户集群/3.配置 Drillbit 共享资源.html">
            
                
                    <a href="../../5.配置 Drill/3.配置一个多租户集群/3.配置 Drillbit 共享资源.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.3.3.</b>
                        
                        3.配置 Drillbit 共享资源
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="5.4" data-path="5.配置 Drill/4.配置模拟身份.html">
            
                
                    <a href="../../5.配置 Drill/4.配置模拟身份.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.4.</b>
                        
                        4.配置模拟身份
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.5" data-path="5.配置 Drill/5.配置用户身份验证.html">
            
                
                    <a href="../../5.配置 Drill/5.配置用户身份验证.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.5.</b>
                        
                        5.配置用户身份验证
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.6" data-path="5.配置 Drill/6.配置 Hive 用户身份验证.html">
            
                
                    <a href="../../5.配置 Drill/6.配置 Hive 用户身份验证.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.6.</b>
                        
                        6.配置 Hive 用户身份验证
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.7" data-path="5.配置 Drill/7.配置 Web 控制台和 REST API 安全.html">
            
                
                    <a href="../../5.配置 Drill/7.配置 Web 控制台和 REST API 安全.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.7.</b>
                        
                        7.配置 Web 控制台和 REST API 安全
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.8" >
            
            <span><b>5.8.</b> 8.可选配置</span>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="5.8.1" data-path="5.配置 Drill/8.可选配置/1.可选配置介绍.html">
            
                
                    <a href="../../5.配置 Drill/8.可选配置/1.可选配置介绍.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.8.1.</b>
                        
                        1.可选配置介绍
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.8.2" data-path="5.配置 Drill/8.可选配置/2.启动可选项.html">
            
                
                    <a href="../../5.配置 Drill/8.可选配置/2.启动可选项.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.8.2.</b>
                        
                        2.启动可选项
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.8.3" data-path="5.配置 Drill/8.可选配置/3.计划和执行可选项.html">
            
                
                    <a href="../../5.配置 Drill/8.可选配置/3.计划和执行可选项.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.8.3.</b>
                        
                        3.计划和执行可选项
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.8.4" data-path="5.配置 Drill/8.可选配置/4.持久化配置存储.html">
            
                
                    <a href="../../5.配置 Drill/8.可选配置/4.持久化配置存储.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.8.4.</b>
                        
                        4.持久化配置存储
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="5.9" data-path="5.配置 Drill/9.Drill 端口使用.html">
            
                
                    <a href="../../5.配置 Drill/9.Drill 端口使用.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.9.</b>
                        
                        9.Drill 端口使用
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.10" data-path="5.配置 Drill/10.配置 Drill 终端.html">
            
                
                    <a href="../../5.配置 Drill/10.配置 Drill 终端.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.10.</b>
                        
                        10.配置 Drill 终端
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="6" >
            
            <span><b>6.</b> 6.连接数据源</span>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="6.1" data-path="6.连接数据源/1.介绍.html">
            
                
                    <a href="../../6.连接数据源/1.介绍.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.1.</b>
                        
                        1.介绍
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.2" data-path="6.连接数据源/2.注册存储插件.html">
            
                
                    <a href="../../6.连接数据源/2.注册存储插件.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.2.</b>
                        
                        2.注册存储插件
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.3" >
            
            <span><b>6.3.</b> 3.配置存储插件</span>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="6.3.1" data-path="6.连接数据源/3.配置存储插件/1.插件基础设置.html">
            
                
                    <a href="../../6.连接数据源/3.配置存储插件/1.插件基础设置.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.3.1.</b>
                        
                        1.插件基础设置
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.3.2" data-path="6.连接数据源/3.配置存储插件/2.工作区间.html">
            
                
                    <a href="../../6.连接数据源/3.配置存储插件/2.工作区间.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.3.2.</b>
                        
                        2.工作区间
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.3.3" data-path="6.连接数据源/3.配置存储插件/3.Drill 默认输出格式.html">
            
                
                    <a href="../../6.连接数据源/3.配置存储插件/3.Drill 默认输出格式.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.3.3.</b>
                        
                        3.Drill 默认输出格式
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="6.4" data-path="6.连接数据源/4.文件系统存储插件.html">
            
                
                    <a href="../../6.连接数据源/4.文件系统存储插件.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.4.</b>
                        
                        4.文件系统存储插件
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.5" data-path="6.连接数据源/5.HBase 存储插件.html">
            
                
                    <a href="../../6.连接数据源/5.HBase 存储插件.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.5.</b>
                        
                        5.HBase 存储插件
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.6" data-path="6.连接数据源/6.Hive 存储插件.html">
            
                
                    <a href="../../6.连接数据源/6.Hive 存储插件.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.6.</b>
                        
                        6.Hive 存储插件
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.7" data-path="6.连接数据源/7.RDBMS 存储插件.html">
            
                
                    <a href="../../6.连接数据源/7.RDBMS 存储插件.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.7.</b>
                        
                        7.RDBMS 存储插件
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.8" data-path="6.连接数据源/8.MongoDB 存储插件.html">
            
                
                    <a href="../../6.连接数据源/8.MongoDB 存储插件.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.8.</b>
                        
                        8.MongoDB 存储插件
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.9" data-path="6.连接数据源/9.S3 存储插件.html">
            
                
                    <a href="../../6.连接数据源/9.S3 存储插件.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.9.</b>
                        
                        9.S3 存储插件
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="7" >
            
            <span><b>7.</b> 7.ODBC 和 JDBC 接口</span>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="7.1" data-path="7.ODBC 和 JDBC 接口/1.介绍.html">
            
                
                    <a href="../../7.ODBC 和 JDBC 接口/1.介绍.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.1.</b>
                        
                        1.介绍
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7.2" data-path="7.ODBC 和 JDBC 接口/2.使用 JDBC 驱动.html">
            
                
                    <a href="../../7.ODBC 和 JDBC 接口/2.使用 JDBC 驱动.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.2.</b>
                        
                        2.使用 JDBC 驱动
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7.3" data-path="7.ODBC 和 JDBC 接口/3.在 Windows 上使用 JDBC 和 SQuirreL.html">
            
                
                    <a href="../../7.ODBC 和 JDBC 接口/3.在 Windows 上使用 JDBC 和 SQuirreL.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.3.</b>
                        
                        3.在 Windows 上使用 JDBC 和 SQuirreL
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7.4" >
            
            <span><b>7.4.</b> 4.安装 ODBC 驱动</span>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="7.4.1" data-path="7.ODBC 和 JDBC 接口/4.安装 ODBC 驱动/1.在 Linux 上安装驱动.html">
            
                
                    <a href="../../7.ODBC 和 JDBC 接口/4.安装 ODBC 驱动/1.在 Linux 上安装驱动.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.4.1.</b>
                        
                        1.在 Linux 上安装驱动
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7.4.2" data-path="7.ODBC 和 JDBC 接口/4.安装 ODBC 驱动/2.在 Mac OS X 上安装驱动.html">
            
                
                    <a href="../../7.ODBC 和 JDBC 接口/4.安装 ODBC 驱动/2.在 Mac OS X 上安装驱动.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.4.2.</b>
                        
                        2.在 Mac OS X 上安装驱动
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7.4.3" data-path="7.ODBC 和 JDBC 接口/4.安装 ODBC 驱动/3.在 Windows 上安装驱动.html">
            
                
                    <a href="../../7.ODBC 和 JDBC 接口/4.安装 ODBC 驱动/3.在 Windows 上安装驱动.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.4.3.</b>
                        
                        3.在 Windows 上安装驱动
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7.4.4" data-path="7.ODBC 和 JDBC 接口/4.安装 ODBC 驱动/4.在 Windows 上安装 TDC 文件.html">
            
                
                    <a href="../../7.ODBC 和 JDBC 接口/4.安装 ODBC 驱动/4.在 Windows 上安装 TDC 文件.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.4.4.</b>
                        
                        4.在 Windows 上安装 TDC 文件
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="7.5" >
            
            <span><b>7.5.</b> 5.配置 ODBC</span>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="7.5.1" data-path="7.ODBC 和 JDBC 接口/5.配置 ODBC/1.ODBC 配置参考.html">
            
                
                    <a href="../../7.ODBC 和 JDBC 接口/5.配置 ODBC/1.ODBC 配置参考.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.5.1.</b>
                        
                        1.ODBC 配置参考
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7.5.2" data-path="7.ODBC 和 JDBC 接口/5.配置 ODBC/2.在 Linux 上配置 ODBC.html">
            
                
                    <a href="../../7.ODBC 和 JDBC 接口/5.配置 ODBC/2.在 Linux 上配置 ODBC.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.5.2.</b>
                        
                        2.在 Linux 上配置 ODBC
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7.5.3" data-path="7.ODBC 和 JDBC 接口/5.配置 ODBC/3.在 Max OS X 上配置 ODBC.html">
            
                
                    <a href="../../7.ODBC 和 JDBC 接口/5.配置 ODBC/3.在 Max OS X 上配置 ODBC.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.5.3.</b>
                        
                        3.在 Max OS X 上配置 ODBC
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7.5.4" data-path="7.ODBC 和 JDBC 接口/5.配置 ODBC/4.在 Windows 上配置 ODBC.html">
            
                
                    <a href="../../7.ODBC 和 JDBC 接口/5.配置 ODBC/4.在 Windows 上配置 ODBC.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.5.4.</b>
                        
                        4.在 Windows 上配置 ODBC
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7.5.5" data-path="7.ODBC 和 JDBC 接口/5.配置 ODBC/5.测试 ODBC 连接.html">
            
                
                    <a href="../../7.ODBC 和 JDBC 接口/5.配置 ODBC/5.测试 ODBC 连接.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.5.5.</b>
                        
                        5.测试 ODBC 连接
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="7.6" >
            
            <span><b>7.6.</b> 6.使用 Drill</span>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="7.6.1" data-path="7.ODBC 和 JDBC 接口/6.使用 Drill/1.介绍.html">
            
                
                    <a href="../../7.ODBC 和 JDBC 接口/6.使用 Drill/1.介绍.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.6.1.</b>
                        
                        1.介绍
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7.6.2" data-path="7.ODBC 和 JDBC 接口/6.使用 Drill/2.连接 Drill 到数据源.html">
            
                
                    <a href="../../7.ODBC 和 JDBC 接口/6.使用 Drill/2.连接 Drill 到数据源.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.6.2.</b>
                        
                        2.连接 Drill 到数据源
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7.6.3" data-path="7.ODBC 和 JDBC 接口/6.使用 Drill/3.浏览数据和定义视图.html">
            
                
                    <a href="../../7.ODBC 和 JDBC 接口/6.使用 Drill/3.浏览数据和定义视图.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.6.3.</b>
                        
                        3.浏览数据和定义视图
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="7.7" >
            
            <span><b>7.7.</b> 7.用 BI 工具连接 Drill</span>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="7.7.1" data-path="7.ODBC 和 JDBC 接口/7.用 BI 工具连接 Drill/1.介绍.html">
            
                
                    <a href="../../7.ODBC 和 JDBC 接口/7.用 BI 工具连接 Drill/1.介绍.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.7.1.</b>
                        
                        1.介绍
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7.7.2" data-path="7.ODBC 和 JDBC 接口/7.用 BI 工具连接 Drill/2.Tableau 示例.html">
            
                
                    <a href="../../7.ODBC 和 JDBC 接口/7.用 BI 工具连接 Drill/2.Tableau 示例.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.7.2.</b>
                        
                        2.使用 JDBC 驱动
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7.7.3" data-path="7.ODBC 和 JDBC 接口/7.用 BI 工具连接 Drill/3.使用 MicroStrategy 分析.html">
            
                
                    <a href="../../7.ODBC 和 JDBC 接口/7.用 BI 工具连接 Drill/3.使用 MicroStrategy 分析.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.7.3.</b>
                        
                        3.在 Windows 上使用 JDBC 和 SQuirreL
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7.7.4" data-path="7.ODBC 和 JDBC 接口/7.用 BI 工具连接 Drill/4.使用 Tibco Spotfire 客户端.html">
            
                
                    <a href="../../7.ODBC 和 JDBC 接口/7.用 BI 工具连接 Drill/4.使用 Tibco Spotfire 客户端.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.7.4.</b>
                        
                        4.使用 Tibco Spotfire 客户端
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7.7.5" data-path="7.ODBC 和 JDBC 接口/7.用 BI 工具连接 Drill/5.使用 Qlik Sense.html">
            
                
                    <a href="../../7.ODBC 和 JDBC 接口/7.用 BI 工具连接 Drill/5.使用 Qlik Sense.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.7.5.</b>
                        
                        5.使用 Qlik Sense
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7.7.6" data-path="7.ODBC 和 JDBC 接口/7.用 BI 工具连接 Drill/6.使用 Tableau 9 客户端.html">
            
                
                    <a href="../../7.ODBC 和 JDBC 接口/7.用 BI 工具连接 Drill/6.使用 Tableau 9 客户端.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.7.6.</b>
                        
                        6.使用 Tableau 9 客户端
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7.7.7" data-path="7.ODBC 和 JDBC 接口/7.用 BI 工具连接 Drill/7.使用 Tableau 9 服务端.html">
            
                
                    <a href="../../7.ODBC 和 JDBC 接口/7.用 BI 工具连接 Drill/7.使用 Tableau 9 服务端.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.7.7.</b>
                        
                        7.使用 Tableau 9 服务端
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7.7.8" data-path="7.ODBC 和 JDBC 接口/7.用 BI 工具连接 Drill/8.配置 JReport.html">
            
                
                    <a href="../../7.ODBC 和 JDBC 接口/7.用 BI 工具连接 Drill/8.配置 JReport.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.7.8.</b>
                        
                        8.配置 JReport
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    

            </ul>
            
        </li>
    


            
            <li class="divider"></li>
            <li>
                <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
                    本书使用 GitBook 发布
                </a>
            </li>
            
        </ul>
    </nav>
</div>

    <div class="book-body">
        <div class="body-inner">
            <div class="book-header" role="navigation">
    <!-- Actions Left -->
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../../" >Apache Drill</a>
    </h1>
</div>

            <div class="page-wrapper" tabindex="-1" role="main">
                <div class="page-inner">
                
                
                    <section class="normal" id="section-">
                    
                        <h1 id="&#x8BFE;&#x7A0B;2&#xFF1A;&#x4F7F;&#x7528;-ansi-sql-&#x67E5;&#x8BE2;">&#x8BFE;&#x7A0B;2&#xFF1A;&#x4F7F;&#x7528; ANSI SQL &#x67E5;&#x8BE2;</h1>
<h2 id="&#x76EE;&#x6807;">&#x76EE;&#x6807;</h2>
<p>&#x672C;&#x8282;&#x8BFE;&#x5C55;&#x793A;&#x5728; Apache Drill &#x4E2D;&#x5982;&#x4F55;&#x53BB;&#x4F7F;&#x7528;&#x6807;&#x51C6;&#x7684; SQL &#x505A;&#x5206;&#x6790;&#xFF1A;&#x4F8B;&#x5982;&#xFF0C;&#x4F7F;&#x7528;&#x805A;&#x5408;&#x51FD;&#x6570;&#x548C; JOIN &#x7528;&#x6CD5;&#x3002;&#x503C;&#x5F97;&#x6CE8;&#x610F;&#x7684;&#x662F;&#xFF0C;Apache Drill &#x63D0;&#x4F9B; ANSI SQL &#x652F;&#x6301;&#xFF0C;&#x800C;&#x4E0D;&#x662F;&#x4E00;&#x4E2A; SQL &#x63A5;&#x53E3;&#x3002;</p>
<h2 id="&#x67E5;&#x8BE2;">&#x67E5;&#x8BE2;</h2>
<p>&#x73B0;&#x5728;&#xFF0C;&#x4F60;&#x77E5;&#x9053;&#x4E86;&#x6570;&#x636E;&#x6E90;&#x7684;&#x539F;&#x59CB;&#x5F62;&#x5F0F;&#xFF0C;&#x4F7F;&#x7528; <code>select *</code> &#x53BB;&#x67E5;&#x8BE2;&#xFF0C;&#x5C1D;&#x8BD5;&#x5728;&#x6BCF;&#x4E2A;&#x6570;&#x636E;&#x6E90;&#x4E0A;&#x8FD0;&#x884C;&#x4E00;&#x4E9B;&#x7B80;&#x5355;&#x4F46;&#x66F4;&#x6709;&#x7528;&#x7684;&#x67E5;&#x8BE2;&#x3002;&#x8FD9;&#x4E9B;&#x67E5;&#x8BE2;&#x6F14;&#x793A;&#x4E86; Drill &#x662F;&#x5982;&#x4F55;&#x652F;&#x6301; ANSI SQL&#xFF0C;&#x5E76;&#x4E14;&#x662F;&#x5982;&#x4F55;&#x5728;&#x4E00;&#x4E2A; <code>SELECT</code> &#x8BED;&#x53E5;&#x4E2D;&#x7ED3;&#x5408;&#x4E0D;&#x540C;&#x6570;&#x636E;&#x6E90;&#x7684;&#x6570;&#x636E;&#x7684;&#x3002;</p>
<ul>
<li>&#x5C55;&#x793A;&#x805A;&#x5408;&#x67E5;&#x8BE2;&#x5728;&#x4E00;&#x4E2A;&#x5355;&#x72EC;&#x7684;&#x6587;&#x4EF6;&#x6216;&#x662F;&#x8868;&#x4E2D;&#x3002;&#x4F7F;&#x7528; <code>GROUP BY&#xFF0C; WHERE&#xFF0C; HAVING&#xFF0C; ORDER BY</code> &#x8BED;&#x6CD5;&#x3002;</li>
<li>&#x5728; Hive&#xFF0C;MapR-DB&#xFF0C;&#x548C;&#x6587;&#x4EF6;&#x7CFB;&#x7EDF;&#x7684;&#x6570;&#x636E;&#x6E90;&#x4E2D;&#x6267;&#x884C; <code>JOIN</code>&#x3002;</li>
<li>&#x4F7F;&#x7528;&#x8868;&#x548C;&#x5217;&#x7684;&#x522B;&#x540D;&#x3002;</li>
<li>&#x521B;&#x5EFA;&#x4E00;&#x4E2A; Drill &#x89C6;&#x56FE;&#x3002;</li>
</ul>
<h2 id="&#x805A;&#x5408;">&#x805A;&#x5408;</h2>
<h3 id="&#x5207;&#x6362;&#x5230;-hive-&#x7684;-schema&#xFF1A;">&#x5207;&#x6362;&#x5230; hive &#x7684; schema&#xFF1A;</h3>
<pre><code class="lang-bash"><span class="hljs-number">0</span>: jdbc:drill:&gt; use hive.`default`;
+-------+-------------------------------------------+
|  ok   |                  summary                  |
+-------+-------------------------------------------+
| <span class="hljs-literal">true</span>  | Default schema changed to [hive.default]  |
+-------+-------------------------------------------+
<span class="hljs-number">1</span> row selected
</code></pre>
<h3 id="&#x6309;&#x6708;&#x8FD4;&#x56DE;&#x9500;&#x552E;&#x603B;&#x91CF;&#xFF1A;">&#x6309;&#x6708;&#x8FD4;&#x56DE;&#x9500;&#x552E;&#x603B;&#x91CF;&#xFF1A;</h3>
<pre><code class="lang-bash"><span class="hljs-number">0</span>: jdbc:drill:&gt; select `month`, sum(order_total)
from orders group by `month` order by <span class="hljs-number">2</span> desc;
+------------+---------+
|   month    | EXPR<span class="hljs-variable">$1</span>  |
+------------+---------+
| June       | <span class="hljs-number">950481</span>  |
| May        | <span class="hljs-number">947796</span>  |
| March      | <span class="hljs-number">836809</span>  |
| April      | <span class="hljs-number">807291</span>  |
| July       | <span class="hljs-number">757395</span>  |
| October    | <span class="hljs-number">676236</span>  |
| August     | <span class="hljs-number">572269</span>  |
| February   | <span class="hljs-number">532901</span>  |
| September  | <span class="hljs-number">373100</span>  |
| January    | <span class="hljs-number">346536</span>  |
+------------+---------+
<span class="hljs-number">10</span> rows selected
</code></pre>
<p>Drill &#x662F;&#x652F;&#x6301; SQL &#x7684;&#x805A;&#x5408;&#x51FD;&#x6570;&#x7684;&#xFF0C;&#x4F8B;&#x5982; SUM&#xFF0C;MAX&#xFF0C;AVG &#x548C; MIN&#x3002;&#x6807;&#x51C6;&#x7684; SQL &#x8BED;&#x6CD5;&#x4EE5;&#x540C;&#x6837;&#x7684;&#x65B9;&#x5F0F;&#x8FD0;&#x884C;&#x5728; Drill &#x67E5;&#x8BE2;&#x4E2D;&#x662F;&#x548C;&#x5173;&#x7CFB;&#x578B;&#x6570;&#x636E;&#x5E93;&#x4E00;&#x6837;&#x7684;&#x3002;</p>
<p>&#x9700;&#x8981;&#x6CE8;&#x610F;&#x7684;&#x662F;&#xFF0C;&#x6807;&#x8BB0;&#x8FD4;&#x56DE;&#x7684; &#x201C;month&#x201D; &#x5217;&#x662F;&#x56E0;&#x4E3A;&#x5176;&#x5728; SQL &#x4E2D;&#x662F;&#x4FDD;&#x7559;&#x5B57;&#x7B26;&#xFF0C;&#x6240;&#x4EE5;&#xFF0C;&#x9700;&#x8981;&#x52A0;&#x4E0A;&#x5F15;&#x53F7;&#x3002;</p>
<h3 id="&#x6309;-month-&#x548C;-state-&#x5B57;&#x6BB5;&#x5206;&#x7EC4;&#xFF0C;&#x8FD4;&#x56DE;&#x524D;-20-&#x884C;&#x9500;&#x552E;&#x603B;&#x989D;&#xFF1A;">&#x6309; month &#x548C; state &#x5B57;&#x6BB5;&#x5206;&#x7EC4;&#xFF0C;&#x8FD4;&#x56DE;&#x524D; 20 &#x884C;&#x9500;&#x552E;&#x603B;&#x989D;&#xFF1A;</h3>
<pre><code class="lang-bash"><span class="hljs-number">0</span>: jdbc:drill:&gt; select `month`, state, sum(order_total) as sales from orders group by `month`, state
order by <span class="hljs-number">3</span> desc <span class="hljs-built_in">limit</span> <span class="hljs-number">20</span>;
+-----------+--------+---------+
|   month   | state  |  sales  |
+-----------+--------+---------+
| May       | ca     | <span class="hljs-number">119586</span>  |
| June      | ca     | <span class="hljs-number">116322</span>  |
| April     | ca     | <span class="hljs-number">101363</span>  |
| March     | ca     | <span class="hljs-number">99540</span>   |
| July      | ca     | <span class="hljs-number">90285</span>   |
| October   | ca     | <span class="hljs-number">80090</span>   |
| June      | tx     | <span class="hljs-number">78363</span>   |
| May       | tx     | <span class="hljs-number">77247</span>   |
| March     | tx     | <span class="hljs-number">73815</span>   |
| August    | ca     | <span class="hljs-number">71255</span>   |
| April     | tx     | <span class="hljs-number">68385</span>   |
| July      | tx     | <span class="hljs-number">63858</span>   |
| February  | ca     | <span class="hljs-number">63527</span>   |
| June      | fl     | <span class="hljs-number">62199</span>   |
| June      | ny     | <span class="hljs-number">62052</span>   |
| May       | fl     | <span class="hljs-number">61651</span>   |
| May       | ny     | <span class="hljs-number">59369</span>   |
| October   | tx     | <span class="hljs-number">55076</span>   |
| March     | fl     | <span class="hljs-number">54867</span>   |
| March     | ny     | <span class="hljs-number">52101</span>   |
+-----------+--------+---------+
<span class="hljs-number">20</span> rows selected
</code></pre>
<p>&#x503C;&#x5F97;&#x4E00;&#x63D0;&#x7684;&#x662F;&#xFF0C;&#x8FD9;&#x91CC;&#x5C06;&#x522B;&#x540D;&#x7528;&#x5728;&#x4E86; SUM &#x805A;&#x5408;&#x51FD;&#x6570;&#x4E0A;&#x3002;Drill &#x662F;&#x652F;&#x6301;&#x5217;&#x522B;&#x540D;&#x548C;&#x8868;&#x522B;&#x540D;&#x7684;&#x3002;</p>
<h2 id="having-&#x8BED;&#x6CD5;">HAVING &#x8BED;&#x6CD5;</h2>
<p>&#x4F7F;&#x7528; <code>HAVING</code> &#x8BED;&#x6CD5;&#x6765;&#x7EA6;&#x675F;&#x805A;&#x5408;&#x7ED3;&#x679C;&#x3002;</p>
<h3 id="&#x5207;&#x6362;&#x5230;-dfsclicks-&#x5DE5;&#x4F5C;&#x533A;&#x95F4;">&#x5207;&#x6362;&#x5230; dfs.clicks &#x5DE5;&#x4F5C;&#x533A;&#x95F4;</h3>
<pre><code class="lang-bash"><span class="hljs-number">0</span>: jdbc:drill:&gt; use dfs.clicks;
+-------+-----------------------------------------+
|  ok   |                 summary                 |
+-------+-----------------------------------------+
| <span class="hljs-literal">true</span>  | Default schema changed to [dfs.clicks]  |
+-------+-----------------------------------------+
<span class="hljs-number">1</span> row selected
</code></pre>
<h3 id="&#x6309;&#x8BBE;&#x5907;&#x5206;&#x7EC4;&#xFF0C;&#x8BBE;&#x5907;&#x70B9;&#x51FB;&#x6570;&#x9AD8;&#x8FC7;&#x4E00;&#x5B9A;&#x9600;&#x503C;&#x7684;&#x603B;&#x6570;&#xFF1A;">&#x6309;&#x8BBE;&#x5907;&#x5206;&#x7EC4;&#xFF0C;&#x8BBE;&#x5907;&#x70B9;&#x51FB;&#x6570;&#x9AD8;&#x8FC7;&#x4E00;&#x5B9A;&#x9600;&#x503C;&#x7684;&#x603B;&#x6570;&#xFF1A;</h3>
<pre><code class="lang-bash"><span class="hljs-number">0</span>: jdbc:drill:&gt; select t.user_info.device, count(*) from `clicks/clicks.json` t
group by t.user_info.device
having count(*) &gt; <span class="hljs-number">1000</span>;
+---------+---------+
| EXPR<span class="hljs-variable">$0</span>  | EXPR<span class="hljs-variable">$1</span>  |
+---------+---------+
| IOS5    | <span class="hljs-number">11814</span>   |
| AOS4.<span class="hljs-number">2</span>  | <span class="hljs-number">5986</span>    |
| IOS6    | <span class="hljs-number">4464</span>    |
| IOS7    | <span class="hljs-number">3135</span>    |
| AOS4.<span class="hljs-number">4</span>  | <span class="hljs-number">1562</span>    |
| AOS4.<span class="hljs-number">3</span>  | <span class="hljs-number">3039</span>    |
+---------+---------+
<span class="hljs-number">6</span> rows selected
</code></pre>
<p>&#x805A;&#x5408;&#x51FD;&#x6570;&#x4ECE;&#x70B9;&#x51FB;&#x91CF;&#x7684;&#x6570;&#x636E;&#x4E2D;&#xFF0C;&#x7EDF;&#x8BA1;&#x4E0D;&#x540C;&#x624B;&#x673A;&#x8BBE;&#x5907;&#x7684;&#x70B9;&#x51FB;&#x91CF;&#x3002;&#x5728;&#x67E5;&#x8BE2;&#x662F;&#x9644;&#x52A0;&#x6FC0;&#x6D3B;&#x548C;&#x6CE8;&#x518C;&#x7684;&#x8BBE;&#x5907;&#x603B;&#x91CF;&#x5FC5;&#x987B;&#x5927;&#x4E8E; 1000&#xFF0C;&#x65B9;&#x80FD;&#x8FD4;&#x56DE;&#x7EDF;&#x8BA1;&#x7ED3;&#x679C;&#x3002;</p>
<h2 id="union-&#x64CD;&#x4F5C;">UNION &#x64CD;&#x4F5C;</h2>
<p>&#x548C;&#x4E4B;&#x524D;&#x76F8;&#x540C;&#x7684;&#x5DE5;&#x4F5C;&#x533A;&#x95F4;&#xFF08;dfs.clicks&#xFF09;&#x3002;</p>
<h3 id="clicks-&#x548C;-campaign-&#x7684;-union-&#x7528;&#x6CD5;">clicks &#x548C; campaign &#x7684; UNION &#x7528;&#x6CD5;</h3>
<pre><code class="lang-bash"><span class="hljs-number">0</span>: jdbc:drill:&gt; select t.trans_id transaction, t.user_info.cust_id customer from `clicks/clicks.campaign.json` t
union all
select u.trans_id, u.user_info.cust_id  from `clicks/clicks.json` u <span class="hljs-built_in">limit</span> <span class="hljs-number">5</span>;
+-------------+------------+
| transaction |  customer  |
+-------------+------------+
| <span class="hljs-number">35232</span>       | <span class="hljs-number">18520</span>      |
| <span class="hljs-number">31995</span>       | <span class="hljs-number">17182</span>      |
| <span class="hljs-number">35760</span>       | <span class="hljs-number">18228</span>      |
| <span class="hljs-number">37090</span>       | <span class="hljs-number">17015</span>      |
| <span class="hljs-number">37838</span>       | <span class="hljs-number">18737</span>      |
+-------------+------------+
</code></pre>
<p>UNION all &#x67E5;&#x8BE2;&#x5B58;&#x5728;&#x4E8E; <code>clicks.campaign.json &#x548C; clicks.json</code> &#x4E24;&#x4E2A;&#x6587;&#x4EF6;&#x4E2D;&#x7684;&#x6240;&#x6709;&#x8BB0;&#x5F55;&#x3002;</p>
<h2 id="&#x5B50;&#x67E5;&#x8BE2;">&#x5B50;&#x67E5;&#x8BE2;</h2>
<h3 id="&#x5207;&#x6362;&#x5DE5;&#x4F5C;&#x7A7A;&#x95F4;&#xFF1A;">&#x5207;&#x6362;&#x5DE5;&#x4F5C;&#x7A7A;&#x95F4;&#xFF1A;</h3>
<pre><code class="lang-bash"><span class="hljs-number">0</span>: jdbc:drill:&gt; use hive.`default`;
+-------+-------------------------------------------+
|  ok   |                  summary                  |
+-------+-------------------------------------------+
| <span class="hljs-literal">true</span>  | Default schema changed to [hive.default]  |
+-------+-------------------------------------------+
<span class="hljs-number">1</span> row selected
</code></pre>
<h3 id="&#x901A;&#x8FC7;-state-&#x6BD4;&#x8F83;-order-&#x7684;&#x603B;&#x91CF;&#xFF1A;">&#x901A;&#x8FC7; state &#x6BD4;&#x8F83; order &#x7684;&#x603B;&#x91CF;&#xFF1A;</h3>
<pre><code class="lang-bash"><span class="hljs-number">0</span>: jdbc:drill:&gt; select ny_sales.cust_id, ny_sales.total_orders, ca_sales.total_orders
from
(select o.cust_id, sum(o.order_total) as total_orders from hive.orders o <span class="hljs-built_in">where</span> state = <span class="hljs-string">&apos;ny&apos;</span> group by o.cust_id) ny_sales
left outer join
(select o.cust_id, sum(o.order_total) as total_orders from hive.orders o <span class="hljs-built_in">where</span> state = <span class="hljs-string">&apos;ca&apos;</span> group by o.cust_id) ca_sales
on ny_sales.cust_id = ca_sales.cust_id
order by ny_sales.cust_id
<span class="hljs-built_in">limit</span> <span class="hljs-number">20</span>;
+------------+------------+------------+
|  cust_id   |  ny_sales  |  ca_sales  |
+------------+------------+------------+
| <span class="hljs-number">1001</span>       | <span class="hljs-number">72</span>         | <span class="hljs-number">47</span>         |
| <span class="hljs-number">1002</span>       | <span class="hljs-number">108</span>        | <span class="hljs-number">198</span>        |
| <span class="hljs-number">1003</span>       | <span class="hljs-number">83</span>         | null       |
| <span class="hljs-number">1004</span>       | <span class="hljs-number">86</span>         | <span class="hljs-number">210</span>        |
| <span class="hljs-number">1005</span>       | <span class="hljs-number">168</span>        | <span class="hljs-number">153</span>        |
| <span class="hljs-number">1006</span>       | <span class="hljs-number">29</span>         | <span class="hljs-number">326</span>        |
| <span class="hljs-number">1008</span>       | <span class="hljs-number">105</span>        | <span class="hljs-number">168</span>        |
| <span class="hljs-number">1009</span>       | <span class="hljs-number">443</span>        | <span class="hljs-number">127</span>        |
| <span class="hljs-number">1010</span>       | <span class="hljs-number">75</span>         | <span class="hljs-number">18</span>         |
| <span class="hljs-number">1012</span>       | <span class="hljs-number">110</span>        | null       |
| <span class="hljs-number">1013</span>       | <span class="hljs-number">19</span>         | null       |
| <span class="hljs-number">1014</span>       | <span class="hljs-number">106</span>        | <span class="hljs-number">162</span>        |
| <span class="hljs-number">1015</span>       | <span class="hljs-number">220</span>        | <span class="hljs-number">153</span>        |
| <span class="hljs-number">1016</span>       | <span class="hljs-number">85</span>         | <span class="hljs-number">159</span>        |
| <span class="hljs-number">1017</span>       | <span class="hljs-number">82</span>         | <span class="hljs-number">56</span>         |
| <span class="hljs-number">1019</span>       | <span class="hljs-number">37</span>         | <span class="hljs-number">196</span>        |
| <span class="hljs-number">1020</span>       | <span class="hljs-number">193</span>        | <span class="hljs-number">165</span>        |
| <span class="hljs-number">1022</span>       | <span class="hljs-number">124</span>        | null       |
| <span class="hljs-number">1023</span>       | <span class="hljs-number">166</span>        | <span class="hljs-number">149</span>        |
| <span class="hljs-number">1024</span>       | <span class="hljs-number">233</span>        | null       |
+------------+------------+------------+
</code></pre>
<p>&#x672C;&#x793A;&#x4F8B;&#x6F14;&#x793A; Drill &#x652F;&#x6301;&#x5B50;&#x67E5;&#x8BE2;&#x3002;</p>
<h2 id="cast-&#x51FD;&#x6570;">CAST &#x51FD;&#x6570;</h2>
<h3 id="&#x5207;&#x6362;&#x5230;-maprdb-&#x5DE5;&#x4F5C;&#x533A;&#x95F4;&#xFF1A;">&#x5207;&#x6362;&#x5230; maprdb &#x5DE5;&#x4F5C;&#x533A;&#x95F4;&#xFF1A;</h3>
<pre><code class="lang-bash"><span class="hljs-number">0</span>: jdbc:drill:&gt; use maprdb;
+-------+-------------------------------------+
|  ok   |               summary               |
+-------+-------------------------------------+
| <span class="hljs-literal">true</span>  | Default schema changed to [maprdb]  |
+-------+-------------------------------------+
<span class="hljs-number">1</span> row selected (<span class="hljs-number">0.088</span> seconds)
</code></pre>
<h3 id="&#x8FD4;&#x56DE;&#x6D88;&#x8D39;&#x6570;&#x636E;&#x7684;&#x6570;&#x636E;&#x7C7B;&#x578B;">&#x8FD4;&#x56DE;&#x6D88;&#x8D39;&#x6570;&#x636E;&#x7684;&#x6570;&#x636E;&#x7C7B;&#x578B;</h3>
<pre><code class="lang-bash"><span class="hljs-number">0</span>: jdbc:drill:&gt; select cast(row_key as int) as cust_id, cast(t.personal.name as varchar(<span class="hljs-number">20</span>)) as name,
cast(t.personal.gender as varchar(<span class="hljs-number">10</span>)) as gender, cast(t.personal.age as varchar(<span class="hljs-number">10</span>)) as age,
cast(t.address.state as varchar(<span class="hljs-number">4</span>)) as state, cast(t.loyalty.agg_rev as dec(<span class="hljs-number">7</span>,<span class="hljs-number">2</span>)) as agg_rev,
cast(t.loyalty.membership as varchar(<span class="hljs-number">20</span>)) as membership
from customers t <span class="hljs-built_in">limit</span> <span class="hljs-number">5</span>;
+----------+----------------------+-----------+-----------+--------+----------+-------------+
| cust_id  |         name         |  gender   |    age    | state  | agg_rev  | membership  |
+----------+----------------------+-----------+-----------+--------+----------+-------------+
| <span class="hljs-number">10001</span>    | <span class="hljs-string">&quot;Corrine Mecham&quot;</span>     | <span class="hljs-string">&quot;FEMALE&quot;</span>  | <span class="hljs-string">&quot;15-20&quot;</span>   | <span class="hljs-string">&quot;va&quot;</span>   | <span class="hljs-number">197.00</span>   | <span class="hljs-string">&quot;silver&quot;</span>    |
| <span class="hljs-number">10005</span>    | <span class="hljs-string">&quot;Brittany Park&quot;</span>      | <span class="hljs-string">&quot;MALE&quot;</span>    | <span class="hljs-string">&quot;26-35&quot;</span>   | <span class="hljs-string">&quot;in&quot;</span>   | <span class="hljs-number">230.00</span>   | <span class="hljs-string">&quot;silver&quot;</span>    |
| <span class="hljs-number">10006</span>    | <span class="hljs-string">&quot;Rose Lokey&quot;</span>         | <span class="hljs-string">&quot;MALE&quot;</span>    | <span class="hljs-string">&quot;26-35&quot;</span>   | <span class="hljs-string">&quot;ca&quot;</span>   | <span class="hljs-number">250.00</span>   | <span class="hljs-string">&quot;silver&quot;</span>    |
| <span class="hljs-number">10007</span>    | <span class="hljs-string">&quot;James Fowler&quot;</span>       | <span class="hljs-string">&quot;FEMALE&quot;</span>  | <span class="hljs-string">&quot;51-100&quot;</span>  | <span class="hljs-string">&quot;me&quot;</span>   | <span class="hljs-number">263.00</span>   | <span class="hljs-string">&quot;silver&quot;</span>    |
| <span class="hljs-number">10010</span>    | <span class="hljs-string">&quot;Guillermo Koehler&quot;</span>  | <span class="hljs-string">&quot;OTHER&quot;</span>   | <span class="hljs-string">&quot;51-100&quot;</span>  | <span class="hljs-string">&quot;mn&quot;</span>   | <span class="hljs-number">202.00</span>   | <span class="hljs-string">&quot;silver&quot;</span>    |
+----------+----------------------+-----------+-----------+--------+----------+-------------+
</code></pre>
<p>&#x6CE8;&#x610F;&#x4EE5;&#x4E0B;&#x67E5;&#x8BE2;&#x8981;&#x70B9;&#xFF1A;</p>
<ul>
<li>CAST &#x51FD;&#x6570;&#x662F;&#x9700;&#x8981;&#x4F5C;&#x7528;&#x4E8E;&#x8868;&#x91CC;&#x7684;&#x6BCF;&#x4E2A;&#x5217;&#x7684;&#x3002;&#x51FD;&#x6570;&#x5C06; MapR-DB/HBase &#x7684;&#x4E8C;&#x8FDB;&#x5236;&#x6570;&#x636E;&#x8FD4;&#x56DE;&#x6210;&#x53EF;&#x8BFB;&#x7684;&#x6574;&#x5F62;&#x548C;&#x5B57;&#x7B26;&#x4E32;&#x3002;&#x53E6;&#x5916;&#xFF0C;&#x4F60;&#x9700;&#x8981;&#x4F7F;&#x7528; <code>CONVERT_TO/CONVERT_FROM</code> &#x51FD;&#x6570;&#x53BB;&#x89E3;&#x6790;&#x5B57;&#x7B26;&#x4E32;&#x5217;&#x3002;<code>CONVERT_TO/CONVERT_FROM</code> &#x6BD4; <code>CAST</code> &#x66F4;&#x9AD8;&#x6548;&#x3002;&#x4F7F;&#x7528; <code>CONVERT_TO</code> &#x5C06;&#x4E8C;&#x8FDB;&#x5236;&#x7C7B;&#x578B;&#x8F6C;&#x6362;&#x6210;&#x4EFB;&#x610F;&#x7C7B;&#x578B;&#x3002;</li>
<li>row_key &#x5217;&#x51FD;&#x6570;&#x4F5C;&#x4E3A;&#x4E00;&#x4E2A;&#x8868;&#x7684;&#x4E3B;&#x952E;&#xFF08;&#x672C;&#x6848;&#x4F8B;&#x4E2D;&#x662F;&#x5BA2;&#x6237;&#x7684; ID&#xFF09;&#x3002;</li>
<li>&#x8868;&#x522B;&#x540D;&#x662F;&#x5FC5;&#x987B;&#x7684;&#xFF1B;&#x5426;&#x5219;&#x5217;&#x7C07;&#x540D;&#x5C06;&#x4F1A;&#x88AB;&#x89E3;&#x6790;&#x4E3A;&#x8868;&#x540D;&#xFF0C;&#x4ECE;&#x800C;&#x8FD4;&#x56DE;&#x67E5;&#x8BE2;&#x9519;&#x8BEF;&#x3002;</li>
</ul>
<h3 id="&#x4ECE;&#x5B57;&#x7B26;&#x4E32;&#x4E2D;&#x5220;&#x9664;&#x5F15;&#x53F7;">&#x4ECE;&#x5B57;&#x7B26;&#x4E32;&#x4E2D;&#x5220;&#x9664;&#x5F15;&#x53F7;</h3>
<p>&#x4F60;&#x53EF;&#x4EE5;&#x4F7F;&#x7528; <code>regexp_replace</code> &#x51FD;&#x6570;&#xFF0C;&#x53BB;&#x5220;&#x9664;&#x67E5;&#x8BE2;&#x7ED3;&#x679C;&#x4E2D;&#x7684;&#x5F15;&#x53F7;&#x3002;&#x4F8B;&#x5982;&#xFF0C;&#x5C06;&#x4E00;&#x4E2A; state &#x540D;&#x4E0B;&#x7684; &#x201C;va&#x201D; &#x66FF;&#x6362;&#x4E3A; va&#xFF1A;</p>
<pre><code class="lang-bash"><span class="hljs-number">0</span>: jdbc:drill:&gt; select cast(row_key as int), regexp_replace(cast(t.address.state as varchar(<span class="hljs-number">10</span>)),<span class="hljs-string">&apos;&quot;&apos;</span>,<span class="hljs-string">&apos;&apos;</span>)
from customers t <span class="hljs-built_in">limit</span> <span class="hljs-number">1</span>;
+------------+------------+
|   EXPR<span class="hljs-variable">$0</span>   |   EXPR<span class="hljs-variable">$1</span>   |
+------------+------------+
| <span class="hljs-number">10001</span>      | va         |
+------------+------------+
<span class="hljs-number">1</span> row selected
</code></pre>
<h2 id="&#x521B;&#x5EFA;&#x89C6;&#x56FE;&#x547D;&#x4EE4;">&#x521B;&#x5EFA;&#x89C6;&#x56FE;&#x547D;&#x4EE4;</h2>
<h3 id="&#x5207;&#x6362;&#x5230;&#x5DE5;&#x4F5C;&#x533A;&#x95F4;">&#x5207;&#x6362;&#x5230;&#x5DE5;&#x4F5C;&#x533A;&#x95F4;</h3>
<pre><code class="lang-bash"><span class="hljs-number">0</span>: jdbc:drill:&gt; use dfs.views;
+-------+----------------------------------------+
|  ok   |                summary                 |
+-------+----------------------------------------+
| <span class="hljs-literal">true</span>  | Default schema changed to [dfs.views]  |
+-------+----------------------------------------+
<span class="hljs-number">1</span> row selected
</code></pre>
<h3 id="&#x4F7F;&#x7528;&#x4E00;&#x4E2A;&#x53EF;&#x53D8;&#x7684;&#x5DE5;&#x4F5C;&#x533A;&#x95F4;&#xFF1A;">&#x4F7F;&#x7528;&#x4E00;&#x4E2A;&#x53EF;&#x53D8;&#x7684;&#x5DE5;&#x4F5C;&#x533A;&#x95F4;&#xFF1A;</h3>
<p>&#x4E00;&#x4E2A;&#x53EF;&#x53D8;&#xFF08;&#x6216;&#x662F;&#x53EF;&#x5199;&#xFF09;&#x7684;&#x5DE5;&#x4F5C;&#x533A;&#x95F4;&#x662F;&#x80FD;&#x591F;&#x88AB;&#x6267;&#x884C;&#x201C;&#x5199;&#x201D;&#x64CD;&#x4F5C;&#x7684;&#x3002;&#x8FD9;&#x4E2A;&#x5C5E;&#x6027;&#x662F;&#x5B58;&#x50A8;&#x63D2;&#x4EF6;&#x914D;&#x7F6E;&#x7684;&#x4E00;&#x90E8;&#x5206;&#x3002;&#x4F60;&#x53EF;&#x4EE5;&#x521B;&#x5EFA; Drill &#x89C6;&#x56FE;&#x548C;&#x8868;&#x5728;&#x53EF;&#x53D8;&#x7684;&#x5DE5;&#x4F5C;&#x533A;&#x95F4;&#x4E2D;&#x3002;</p>
<h3 id="&#x521B;&#x5EFA;&#x4E00;&#x4E2A;&#x89C6;&#x56FE;&#x5728;-maprdb-&#x8868;">&#x521B;&#x5EFA;&#x4E00;&#x4E2A;&#x89C6;&#x56FE;&#x5728; MapR-DB &#x8868;</h3>
<pre><code class="lang-bash"><span class="hljs-number">0</span>: jdbc:drill:&gt; create or replace view custview as select cast(row_key as int) as cust_id,
cast(t.personal.name as varchar(<span class="hljs-number">20</span>)) as name,
cast(t.personal.gender as varchar(<span class="hljs-number">10</span>)) as gender,
cast(t.personal.age as varchar(<span class="hljs-number">10</span>)) as age,
cast(t.address.state as varchar(<span class="hljs-number">4</span>)) as state,
cast(t.loyalty.agg_rev as dec(<span class="hljs-number">7</span>,<span class="hljs-number">2</span>)) as agg_rev,
cast(t.loyalty.membership as varchar(<span class="hljs-number">20</span>)) as membership
from maprdb.customers t;
+-------+-------------------------------------------------------------+
|  ok   |                           summary                           |
+-------+-------------------------------------------------------------+
| <span class="hljs-literal">true</span>  | View <span class="hljs-string">&apos;custview&apos;</span> created successfully <span class="hljs-keyword">in</span> <span class="hljs-string">&apos;dfs.views&apos;</span> schema  |
+-------+-------------------------------------------------------------+
<span class="hljs-number">1</span> row selected
</code></pre>
<p>Drill &#x63D0;&#x4F9B;&#x4E86;&#x548C;&#x5173;&#x7CFB;&#x578B;&#x6570;&#x636E;&#x5E93;&#x521B;&#x5EFA;&#x89C6;&#x56FE;&#x76F8;&#x4F3C;&#x7684;&#x8BED;&#x6CD5; <code>CREATE OR REPLACE VIEW</code>&#x3002;&#x4F7F;&#x7528; <code>OR REPLACE</code> &#x9009;&#x9879;&#x53EF;&#x4EE5;&#x5F88;&#x65B9;&#x4FBF;&#x7684;&#x53BB;&#x66F4;&#x65B0;&#x89C6;&#x56FE;&#x5230;&#x6700;&#x65B0;&#xFF0C;&#x800C;&#x4E0D;&#x9700;&#x8981;&#x6211;&#x4EEC;&#x5728;&#x521B;&#x5EFA;&#x4E4B;&#x524D;&#x5220;&#x9664;&#x5B83;&#x3002;&#x503C;&#x5F97;&#x6CE8;&#x610F;&#x7684;&#x662F;&#xFF0C;<code>FROM</code> &#x8BED;&#x6CD5;&#x5728;&#x672C;&#x793A;&#x4F8B;&#x4E2D;&#x5FC5;&#x9700;&#x6307;&#x5411; maprdb.customers&#x3002;MapR-DB &#x8868;&#x4E0D;&#x80FD;&#x76F4;&#x63A5;&#x5728; dfs.views &#x7684;&#x5DE5;&#x4F5C;&#x533A;&#x95F4;&#x4E2D;&#x53EF;&#x89C6;&#x5316;&#x3002;</p>
<p>&#x4E0D;&#x50CF;&#x4F20;&#x7EDF;&#x6570;&#x636E;&#x5E93;&#x90A3;&#x6837;&#xFF0C;&#x89C6;&#x56FE;&#x8FD8;&#x9700;&#x8981; DBA/&#x5F00;&#x53D1;&#x9A71;&#x52A8;&#x4E1A;&#x52A1;&#xFF0C;&#x5728; Drill &#x4E2D;&#x89C6;&#x56FE;&#x662F;&#x57FA;&#x4E8E;&#x6587;&#x4EF6;&#x7CFB;&#x7EDF;&#x7684;&#xFF0C;&#x5C5E;&#x4E8E;&#x8F7B;&#x91CF;&#x7EA7;&#x7684;&#x3002;&#x89C6;&#x56FE;&#x53EA;&#x662F;&#x4E00;&#x4E2A;&#x7279;&#x6B8A;&#x7684;&#x6587;&#x4EF6;&#xFF0C;&#x5177;&#x6709;&#x7279;&#x6B8A;&#x7684;&#x6269;&#x5C55;&#x540D;&#xFF08;.drill&#xFF09;&#x3002;&#x4F60;&#x53EF;&#x4EE5;&#x672C;&#x5730;&#x6587;&#x4EF6;&#x7CFB;&#x7EDF;&#x6216;&#x6307;&#x5B9A;&#x7279;&#x5B9A;&#x7684;&#x5DE5;&#x4F5C;&#x533A;&#x95F4;&#x53BB;&#x5B58;&#x50A8;&#x89C6;&#x56FE;&#x3002;&#x4F60;&#x53EF;&#x4EE5;&#x521B;&#x5EFA;&#x89C6;&#x56FE;&#x7684;&#x8BED;&#x53E5;&#x4E2D;&#x6307;&#x5B9A;&#x4EFB;&#x4F55;&#x67E5;&#x8BE2;&#xFF0C;&#x5BF9;&#x4EFB;&#x4F55;&#x6570;&#x636E;&#x6E90;&#x8FDB;&#x884C;&#x67E5;&#x8BE2;&#x3002;</p>
<p>Drill &#x63D0;&#x4F9B;&#x4E86;&#x4E00;&#x4E2A;&#x5206;&#x6563;&#x7684;&#x5143;&#x6570;&#x636E;&#x6A21;&#x578B;&#x3002;Drill &#x80FD;&#x591F;&#x53BB;&#x67E5;&#x8BE2;&#x4E00;&#x4E9B;&#x5B9A;&#x4E49;&#x597D;&#x7684;&#x5143;&#x6570;&#x636E;&#xFF0C;&#x4F8B;&#x5982; Hive&#xFF0C;HBase &#x548C; &#x6587;&#x4EF6;&#x7CFB;&#x7EDF;&#x3002;Drill &#x8FD8;&#x652F;&#x6301;&#x5728;&#x6587;&#x4EF6;&#x7CFB;&#x7EDF;&#x4E2D;&#x521B;&#x5EFA;&#x5143;&#x6570;&#x636E;&#x3002;</p>
<h3 id="&#x4ECE;&#x89C6;&#x56FE;&#x4E2D;&#x67E5;&#x8BE2;&#x6570;&#x636E;&#xFF1A;">&#x4ECE;&#x89C6;&#x56FE;&#x4E2D;&#x67E5;&#x8BE2;&#x6570;&#x636E;&#xFF1A;</h3>
<pre><code class="lang-bash"><span class="hljs-number">0</span>: jdbc:drill:&gt; select * from custview <span class="hljs-built_in">limit</span> <span class="hljs-number">1</span>;
+----------+-------------------+-----------+----------+--------+----------+-------------+
| cust_id  |       name        |  gender   |   age    | state  | agg_rev  | membership  |
+----------+-------------------+-----------+----------+--------+----------+-------------+
| <span class="hljs-number">10001</span>    | <span class="hljs-string">&quot;Corrine Mecham&quot;</span>  | <span class="hljs-string">&quot;FEMALE&quot;</span>  | <span class="hljs-string">&quot;15-20&quot;</span>  | <span class="hljs-string">&quot;va&quot;</span>   | <span class="hljs-number">197.00</span>   | <span class="hljs-string">&quot;silver&quot;</span>    |
+----------+-------------------+-----------+----------+--------+----------+-------------+
<span class="hljs-number">1</span> row selected
</code></pre>
<p>&#x4E00;&#x65E6;&#xFF0C;&#x7528;&#x6237;&#x77E5;&#x9053;&#x54EA;&#x4E9B;&#x6570;&#x636E;&#x662F;&#x76F4;&#x63A5;&#x53EF;&#x4EE5;&#x4ECE;&#x6587;&#x4EF6;&#x7CFB;&#x7EDF;&#x4E2D;&#x53EF;&#x7528;&#x7684;&#xFF0C;&#x89C6;&#x56FE;&#x53EF;&#x4EE5;&#x7528;&#x6765;&#x8BFB;&#x53D6;&#x6570;&#x636E;&#x5230;&#x4E0B;&#x6E38;&#x5DE5;&#x5177;&#xFF0C;&#x4F8B;&#x5982;&#xFF1A;Tableau &#x548C; MicroStrategy &#x7528;&#x4E8E;&#x5206;&#x6790;&#x548C;&#x53EF;&#x89C6;&#x5316;&#x3002;&#x5BF9;&#x4E8E;&#x8FD9;&#x4E9B;&#x5DE5;&#x5177;&#xFF0C;&#x89C6;&#x56FE;&#x662F;&#x4EE5;&#x4E00;&#x4E2A;&#x201C;&#x8868;&#x201D;&#x51FA;&#x73B0;&#x7684;&#xFF0C;&#x5728;&#x5B83;&#x7684;&#x53EF;&#x9009;&#x201C;&#x5217;&#x201D;&#x4E2D;&#x3002;</p>
<h2 id="&#x67E5;&#x8BE2;&#x6570;&#x636E;&#x6E90;">&#x67E5;&#x8BE2;&#x6570;&#x636E;&#x6E90;</h2>
<p>&#x7EE7;&#x7EED;&#x4F7F;&#x7528; <code>dfs.views</code> &#x505A;&#x67E5;&#x8BE2;&#x3002;</p>
<h3 id="&#x8FDE;&#x63A5;&#x7528;&#x6237;&#x89C6;&#x56FE;&#x548C;&#x8BA2;&#x5355;&#x8868;&#xFF1A;">&#x8FDE;&#x63A5;&#x7528;&#x6237;&#x89C6;&#x56FE;&#x548C;&#x8BA2;&#x5355;&#x8868;&#xFF1A;</h3>
<pre><code class="lang-bash"><span class="hljs-number">0</span>: jdbc:drill:&gt; select membership, sum(order_total) as sales from hive.orders, custview
<span class="hljs-built_in">where</span> orders.cust_id=custview.cust_id
group by membership order by <span class="hljs-number">2</span>;
+------------+------------+
| membership |   sales    |
+------------+------------+
| <span class="hljs-string">&quot;basic&quot;</span>    | <span class="hljs-number">380665</span>     |
| <span class="hljs-string">&quot;silver&quot;</span>   | <span class="hljs-number">708438</span>     |
| <span class="hljs-string">&quot;gold&quot;</span>     | <span class="hljs-number">2787682</span>    |
+------------+------------+
<span class="hljs-number">3</span> rows selected
</code></pre>
<p>&#x5728;&#x8BE5;&#x67E5;&#x8BE2;&#x4E2D;&#xFF0C;&#x6211;&#x4EEC;&#x4ECE; MapR-DB &#x8868;&#x4E2D;&#x8BFB;&#x53D6;&#x6570;&#x636E;&#xFF0C;&#x5E76;&#x4E14;&#x7ED3;&#x5408; Hive &#x4E2D;&#x7684;&#x8BA2;&#x5355;&#x4FE1;&#x606F;&#x3002;&#x5F53;&#x8DE8;&#x6570;&#x636E;&#x6E90;&#x67E5;&#x8BE2;&#x662F;&#xFF0C;&#x4F60;&#x9700;&#x8981;&#x5B8C;&#x5168;&#x9650;&#x5B9A;&#x8868;/&#x89C6;&#x56FE;&#x540D;&#x79F0;&#x3002;&#x4F8B;&#x5982;&#xFF0C;&#x8BA2;&#x5355;&#x8868;&#x7684;&#x524D;&#x7F00;&#x662F; &#x201C;hive&#x201D;&#xFF0C;&#x8FD9;&#x4E2A;&#x662F;&#x5B58;&#x50A8;&#x63D2;&#x4EF6;&#x6CE8;&#x518C;&#x5728; Drill &#x4E2D;&#x7684;&#x3002;&#x5BF9;&#x4E8E; &#x201C;custview&#x201D; &#x6211;&#x4EEC;&#x4E0D;&#x4F7F;&#x7528;&#x4EFB;&#x4F55;&#x524D;&#x7F00;&#xFF0C;&#x56E0;&#x4E3A;&#x6211;&#x4EEC;&#x660E;&#x786E;&#x7684;&#x628A; dfs.views workspace &#x5B58;&#x50A8;&#x5728;&#x5DE5;&#x4F5C;&#x533A;&#x95F4;&#x3002;</p>
<p>&#x503C;&#x5F97;&#x6CE8;&#x610F;&#x7684;&#x662F;&#xFF0C;&#x5982;&#x679C;&#x4F60;&#x7684;&#x67E5;&#x8BE2;&#x7ED3;&#x679C;&#x663E;&#x793A;&#x88AB;&#x622A;&#x65AD;&#xFF0C;&#x662F;&#x56E0;&#x4E3A;&#x4F60;&#x7684;&#x884C;&#x592A;&#x957F;&#x4E86;&#xFF0C;&#x5C06;&#x663E;&#x793A;&#x7684;&#x6700;&#x5927;&#x5BBD;&#x5EA6;&#x8BBE;&#x7F6E;&#x4E3A; 10000&#xFF1A;</p>
<p>&#x5728;&#x8BBE;&#x7F6E;&#x547D;&#x4EE4;&#x4E2D;&#x4E0D;&#x8981;&#x4F7F;&#x7528;&#x5206;&#x53F7;&#x3002;</p>
<h3 id="&#x8FDE;&#x63A5;&#x5BA2;&#x6237;&#xFF0C;&#x8BA2;&#x5355;&#x548C;&#x70B9;&#x51FB;&#x91CF;&#x7684;&#x6570;&#x636E;&#xFF1A;">&#x8FDE;&#x63A5;&#x5BA2;&#x6237;&#xFF0C;&#x8BA2;&#x5355;&#x548C;&#x70B9;&#x51FB;&#x91CF;&#x7684;&#x6570;&#x636E;&#xFF1A;</h3>
<pre><code class="lang-bash"><span class="hljs-number">0</span>: jdbc:drill:&gt; select custview.membership, sum(orders.order_total) as sales from hive.orders, custview,
dfs.`/mapr/demo.mapr.com/data/nested/clicks/clicks.json` c
<span class="hljs-built_in">where</span> orders.cust_id=custview.cust_id and orders.cust_id=c.user_info.cust_id
group by custview.membership order by <span class="hljs-number">2</span>;
+------------+------------+
| membership |   sales    |
+------------+------------+
| <span class="hljs-string">&quot;basic&quot;</span>    | <span class="hljs-number">372866</span>     |
| <span class="hljs-string">&quot;silver&quot;</span>   | <span class="hljs-number">728424</span>     |
| <span class="hljs-string">&quot;gold&quot;</span>     | <span class="hljs-number">7050198</span>    |
+------------+------------+
<span class="hljs-number">3</span> rows selected
</code></pre>
<p>&#x4E09;&#x8005;&#x8FDE;&#x63A5;&#x4ECE;&#x4E09;&#x4E2A;&#x4E0D;&#x540C;&#x7684;&#x6570;&#x636E;&#x6E90;&#x4E2D;&#x9009;&#x62E9;&#x4E00;&#x4E2A;&#x67E5;&#x8BE2;&#xFF1A;</p>
<ul>
<li>hive.orders &#x8868;</li>
<li>custview&#xFF08;HBase &#x5BA2;&#x6237;&#x8868;&#x7684;&#x4E00;&#x4E2A;&#x89C6;&#x56FE;&#xFF09;</li>
<li>clicks.json &#x6587;&#x4EF6;</li>
</ul>
<p>&#x8FDE;&#x63A5;&#x5217;&#x4EE5;&#x8FDE;&#x63A5;&#x4E24;&#x8005;&#x7684; cust_id &#x5217;&#x4E3A;&#x6761;&#x4EF6;&#x3002;&#x89C6;&#x56FE;&#x5DE5;&#x4F5C;&#x533A;&#x95F4;&#x7528;&#x4E8E;&#x8BE5;&#x67E5;&#x8BE2;&#xFF0C;&#x4EE5;&#x81F3;&#x4E8E; custview &#x53EF;&#x4EE5;&#x8BBF;&#x95EE;&#x3002;&#x800C; hive.orders &#x8868;&#x7684;&#x67E5;&#x8BE2;&#x4E5F;&#x662F;&#x53EF;&#x89C1;&#x7684;&#x3002;</p>
<p>&#x53E6;&#x5916;&#xFF0C;&#x9700;&#x8981;&#x6CE8;&#x610F;&#x7684;&#x662F;&#xFF0C;JSON &#x6587;&#x4EF6;&#x662F;&#x4E0D;&#x80FD;&#x76F4;&#x63A5;&#x5728;&#x89C6;&#x56FE;&#x5DE5;&#x4F5C;&#x533A;&#x95F4;&#x88AB;&#x53EF;&#x89C6;&#x5316;&#x7684;&#xFF0C;&#x9700;&#x8981;&#x6307;&#x5B9A;&#x67E5;&#x8BE2;&#x6587;&#x4EF6;&#x7684;&#x5168;&#x8DEF;&#x5F84;&#xFF1A;</p>
<pre><code class="lang-bash">dfs.`/mapr/demo.mapr.com/data/nested/clicks/clicks.json`
</code></pre>
<footer class="page-footer"><span class="copyright">Copyright &#xA9; http://drill.smartloli.org 2016 all right reserved&#xFF0C;powered by Gitbook</span><span class="footer-modification">Modify: 
2016-01-09 14:41:54
</span></footer>
                    
                    </section>
                
                
                </div>
            </div>
        </div>

        
        <a href="../../3.教程/4.在 MapR 的 Sandbox 中学习 Drill/4.课程1:学习数据集.html" class="navigation navigation-prev " aria-label="Previous page: 4.课程1:学习数据集"><i class="fa fa-angle-left"></i></a>
        
        
        <a href="../../3.教程/4.在 MapR 的 Sandbox 中学习 Drill/6.课程3:查询复杂的数据类型.html" class="navigation navigation-next " aria-label="Next page: 6.课程3:查询复杂的数据类型"><i class="fa fa-angle-right"></i></a>
        
    </div>
</div>

        
<script src="../../gitbook/app.js"></script>

    
    <script src="../../gitbook/plugins/gitbook-plugin-baidu/plugin.js"></script>
    

    
    <script src="../../gitbook/plugins/gitbook-plugin-sharing/buttons.js"></script>
    

    
    <script src="../../gitbook/plugins/gitbook-plugin-fontsettings/buttons.js"></script>
    

    
    <script src="../../gitbook/plugins/gitbook-plugin-livereload/plugin.js"></script>
    

<script>
require(["gitbook"], function(gitbook) {
    var config = {"tbfed-pagefooter":{"copyright":"Copyright &copy http://drill.smartloli.org 2016","modify_label":"Modify: ","modify_format":"YYYY-MM-DD HH:mm:ss"},"baidu":{"token":""},"fontsettings":{"size":1,"theme":"white","family":"sans"},"highlight":{},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"livereload":{}};
    gitbook.start(config);
});
</script>

        <script>var _hmt = _hmt || [];(function() {var hm = document.createElement('script');hm.src = '//hm.baidu.com/hm.js?';var s = document.getElementsByTagName('script')[0];s.parentNode.insertBefore(hm, s);})();</script>
    </body>
    
</html>
